package com.icode.core.shared;

import com.icode.core.dto.order.OrderDTO;
import com.icode.core.model.manage.Reserve;
import com.icode.core.model.order.Order;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-8-26
 * Time: 上午10:06
 * To change this template use File | Settings | File Templates.
 */
public class ExchangeHandle {

    public static List<OrderDTO> packageExchange(List<Order> orders, List<Reserve> reserves) {
        List<OrderDTO> orderDTOs = new ArrayList<>();
        if (!orders.isEmpty()) {
            for (Order o : orders) {
                if (!reserves.isEmpty()) {
                    for (Reserve r : reserves) {
                        if (r.houseInfo().guid().equals(o.houseInfo().guid())) {
                            orders.remove(o);
                        }
                    }
                }
            }
            orderDTOs = OrderDTO.toDTOs(orders);
        }
        return orderDTOs;
    }
}
